<template>
  <div>
       <!-- 头部开始 -->
        <myheader />
      <!-- 头部结束 -->

      <!-- 表单区域 -->
        <div class="udlite-container partners">
            <van-cell-group>
                <van-field v-model="username" label="用户名" placeholder="请输入用户名" />
                <van-field v-model="password" label="密码" placeholder="请输入密码" />
                <van-field v-model="pwd" label="确认密码" placeholder="请输入确认密码" />
                <van-field v-model="phone" label="手机号" placeholder="请输入手机号" />
                <van-field v-model="email" label="邮箱" placeholder="请输入邮箱" />

                <van-button type="primary" @click="submit">注册</van-button>
                <van-button type="info">重置</van-button>
            </van-cell-group>
        </div>
      <!-- 表单区域 -->

  </div>
</template>

<script>
import myheader from './myheader'

export default {
    data() {
        return {
            username: '',
            password: '',
            pwd: '',
            phone: '',
            email : ''
        }
    },

    // 声明组件
    components:{
        myheader,
    },

    methods:{
        submit:function(){
            if (this.username == ""){
                this.$toast("请填写用户名");
                return false;
            }

            // let data = {
            //     'username': this.username,
            //     'password': this.password,
            //     'pwd': this.pwd,
            //     'phone': this.phone,
            //     'email': this.email
            // }
            this.axios.get('http://localhost:8000/register/', {params:{username:this.username,password:this.password,
            pwd:this.pwd,phone:this.phone,email:this.email}}).then(res=>{
                console.log(res.data)
                if (res.data.code == '200'){
                    alert(res.data.message)
                }
                else{
                    alert(res.data.message)
                }
            })
            

            // 请求后端接口
            // this.axios.get('http://localhost:8000/register/',{params:{username:this.username,password:
            // this.password}}).then(res=>{
            //     console.log(res.data)
            //     if (res.data.code == '200'){
            //         alert(res.data.message)
            //     }
            //     else{
            //         alert(res.data.message)
            //     }
            // })
        }
    }


}
</script>

<style>

</style>